package com.wanshi.servlet;

import com.wanshi.entity.PageInfo;
import com.wanshi.entity.User;
import com.wanshi.service.UserService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/ss/page")
public class PageServlet extends HttpServlet {
    private UserService userService = new UserService();
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        //查询第几页  每页显示多少条数据
        int page = Integer.parseInt(request.getParameter("page"))  ;
        int size =  Integer.parseInt(request.getParameter("size")) ;


        PageInfo pageInfo = userService.findByPage(page,size);
        request.setAttribute("page",pageInfo);
        request.getRequestDispatcher("/page.jsp").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}

